//
//  BezierPathViewController.m
//  XKStudyDemo
//
//  Created by xukai on 2017/11/29.
//  Copyright © 2017年 xukai. All rights reserved.
//

#import "BezierPathViewController.h"
#import "XKBezierView.h"



@interface BezierPathViewController ()

@end

@implementation BezierPathViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    self.view.backgroundColor = [UIColor orangeColor];
    
    [self startDraw];
}

-(void) startDraw
{
    
    UIView *tempView = [[UIView alloc] initWithFrame:self.view.bounds];
    tempView.backgroundColor = [[UIColor grayColor] colorWithAlphaComponent:0.3];
    [self.view addSubview:tempView];
    tempView.center = CGPointMake(SCREEN_WIDHT * 0.5, SCREEN_HEIGHT * 0.5);
    
    
    UIBezierPath *path = [UIBezierPath bezierPathWithRect: tempView.bounds];

    
    UIBezierPath *clearPath = [UIBezierPath bezierPathWithArcCenter:CGPointMake(tempView.width * 0.5, tempView.height * 0.5) radius:100 startAngle:0 endAngle:2 * M_PI clockwise:NO];
    

    [path appendPath:clearPath];
    
    CAShapeLayer *shapeLayer = (CAShapeLayer *)tempView.layer.mask;
    if(!shapeLayer) {
        shapeLayer = [CAShapeLayer layer];
        [tempView.layer setMask: shapeLayer];
    }
    shapeLayer.path = path.CGPath;
    

}




@end
